﻿using System;
using System.Collections;
using Noea.TogSim.Model.Interfaces;

namespace Noea.TogSim.Model.Tracks
{
    public class Railroad
    {
        public static ArrayList TrackList(ITrack start)
        {
            ArrayList trackList = new ArrayList();
            TrackTraverse(start, trackList);
            return trackList;
        }

        private static void TrackTraverse(ITrack start, ArrayList trackList)
        {

            if (start != null && !trackList.Contains(start))
            {
                //Console.WriteLine("traver spor: " + start.Id);
                trackList.Add(start);
                for (int i = 0; i < start.NextList.Length; i++)
                {
                    TrackTraverse(start.NextList[i], trackList);
                }
            }

        }
    }
}
